#include<bits/stdc++.h>
using namespace std;


int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
int main()
{
	int n; cin >> n;  
	int arr[n+1][n+1]={0};
	
	int cnt = 1;
	int pos = 0;
	int i = 1; int j = 1;
	int count = 0;
	while(cnt <= n * n)   
	{
		arr[i][j] = cnt; 
		//判断是否越界
		int a = i + dx[pos]; int b = j + dy[pos];

		if (a<1 || a>n || b<1 || b>n || arr[a][b] != 0)
		{
			//更新坐标
			pos++; pos %= 4;
			 a = i + dx[pos];  b = j + dy[pos];
		}
		i = a; j = b;   
		cnt++;
	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			printf("%3d",arr[i][j]);
		}
		cout << endl; 
	}
	return 0;
}
